<?php

namespace app\controller;

use app\service\TaskRepairService;
use support\Request;
use support\Response;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;

class TaskRepairController
{


    /**
     * @var TaskRepairService
     */
    private $taskRepairService;

    public function __construct()
    {
        $this->taskRepairService = new TaskRepairService();
    }


    public function index(Request $request)
    {
//        $this->taskRepairService->getEffectedTask();
        return response('hello webman');
    }

    /**
     * 返修情况
     * @param Request $request
     * @return Response
     */
    public function getEffectedTaskInfo(Request $request): Response
    {
        $param = $request->post();
        $projectId = $param['project_id'];
        $stepCategoryId = $param['step_category_id'];
        $startTime = $param['start_time'];
        $endTime = $param['end_time'];
        $dataType = $param['data_type'] ?? 'count';
        $res = $this->taskRepairService->getEffectedTaskInfo($projectId, $stepCategoryId, $startTime, $endTime, $dataType);
        return json(success_response('', $res));
    }


}
